package com.gewu.pm.ui.fragment.message;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.gewu.pm.R;
import com.gewu.pm.app.AppActivity;
import com.gewu.pm.app.AppFragment;
import com.gewu.pm.bean.TestBean;
import com.gewu.pm.ui.adapter.SystemNotificationAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * 系统通知 Fragment  暂时没有区分多种类型
 */
public final class SystemNotificationFragment extends AppFragment<AppActivity>
        implements SystemNotificationAdapter.OnDetailsClickListener {

    private RecyclerView mRecyclerView;
    private SystemNotificationAdapter mAdapter;

    public static SystemNotificationFragment newInstance() {
        return new SystemNotificationFragment();
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_system_notification;
    }

    @Override
    protected void initView() {
        mRecyclerView = findViewById(R.id.rv_list);

        mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
        mAdapter = new SystemNotificationAdapter(getContext());
        mAdapter.setOnDetailsClickListener(this);
        mRecyclerView.setAdapter(mAdapter);
    }

    @Override
    protected void initData() {
        loadData();
    }

    /**
     * 加载数据
     */
    private void loadData() {
        List<TestBean> dataList = new ArrayList<>();
        dataList.add(new TestBean("1", "加单通知"));
        dataList.add(new TestBean("2", "减货通知"));
        dataList.add(new TestBean("3", "你的补卡申请已通过审批"));
        dataList.add(new TestBean("4", "你的买赠活动申请已通过审批"));
        dataList.add(new TestBean("5", "李四的补卡申请需要审批"));
        dataList.add(new TestBean("6", "李四创建的买赠活动需要审批"));
        dataList.add(new TestBean("7", "财务向你进行了账单核对"));
        dataList.add(new TestBean("8", "某某超市有了一张待付订单购"));
        dataList.add(new TestBean("9", "落落超市新开了终端成功批此"));
        mAdapter.setData(dataList);
    }

    @Override
    public void onDetailsClick(int position, TestBean item) {
        // TODO: 跳转到详情页面
        toast("点击了查看详情：" + item.getName());
    }
}

